package com.hudson.plugin;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * Promotions entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "promotions", catalog = "reportdb")
public class Promotions implements java.io.Serializable {

    // Fields

    private Integer id;
    private Projects projects;
    private String name;
    private Set<PromotionBuilds> promotionBuildses = new HashSet<PromotionBuilds>(
            0);

    // Constructors

    /**
     * default constructor
     */
    public Promotions() {
    }

    /**
     * full constructor
     */
    public Promotions(Projects projects, String name,
                      Set<PromotionBuilds> promotionBuildses) {
        this.projects = projects;
        this.name = name;
        this.promotionBuildses = promotionBuildses;
    }

    // Property accessors
    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "project_id")
    public Projects getProjects() {
        return this.projects;
    }

    public void setProjects(Projects projects) {
        this.projects = projects;
    }

    @Column(name = "name", length = 64)
    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "promotions")
    public Set<PromotionBuilds> getPromotionBuildses() {
        return this.promotionBuildses;
    }

    public void setPromotionBuildses(Set<PromotionBuilds> promotionBuildses) {
        this.promotionBuildses = promotionBuildses;
    }

}